<template>
	<view class="add-node-btn-box">
		<view class="add-node-btn">
			<m-popover placement="right" ref="Popover" class="item-popover">

				<!-- <button type="primary" size="mini" style="border-radius: 999px;color: #fff;">
					<uni-icons type="plusempty" color="#fff" size="30"></uni-icons>
				</button> -->

				<u-button type="primary" shape="circle" icon="plus"></u-button>

				<template #content>
					<view class="add-node-popover-body" style="padding: 10px;zoom: 0.7;">
						<view class="add-node-popover-item approver" @click="addType(1)">
							<view class="item-wrapper x-c"
								style="display: flex;align-items: center;justify-content: center;">
								<uni-icons color="#ff943e" type="auth-filled" :size="45"></uni-icons>
							</view>
							<view>审批人</view>
						</view>
						<view class="add-node-popover-item notifier" @click="addType(2)">
							<view class="item-wrapper x-c"
								style="display: flex;align-items: center;justify-content: center;">
								<uni-icons color="#3296fa" type="paperplane-filled" :size="45"></uni-icons>
							</view>
							<view>抄送人</view>
						</view>
					</view>
				</template>
			</m-popover>
		</view>
	</view>
</template>

<script>
	export default {
		props: ["childNodeP"],
		data() {
			return {
				visible: false
			};
		},
		methods: {
			addType(type) {
				this.visible = false;
				this.$refs.Popover.close();
				if (type != 4) {
					var data;
					if (type == 1) {
						data = {
							"nodeName": "审核人",
							"error": true,
							"type": 1,
							"settype": 1,
							"selectMode": 0,
							"selectRange": 0,
							"directorLevel": 1,
							"replaceByUp": 0,
							"examineMode": 1,
							"noHanderAction": 1,
							"examineEndDirectorLevel": 0,
							"childNode": this.childNodeP,
							"nodeUserList": []
						}
					} else if (type == 2) {
						data = {
							"nodeName": "抄送人",
							"type": 2,
							"ccSelfSelectFlag": 1,
							"childNode": this.childNodeP,
							"nodeUserList": []
						}
					};
					this.$emit("update:childNodeP", data)
				} else {
					this.$emit("update:childNodeP", {
						"nodeName": "路由",
						"type": 4,
						"childNode": null,
						"conditionNodes": [{
							"nodeName": "条件1",
							"error": true,
							"type": 3,
							"priorityLevel": 1,
							"conditionList": [],
							"nodeUserList": [],
							"childNode": this.childNodeP,
						}, {
							"nodeName": "条件2",
							"type": 3,
							"priorityLevel": 2,
							"conditionList": [],
							"nodeUserList": [],
							"childNode": null
						}]
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	@import '@/uni_modules/mc-ui/static/css/workflow.css';
</style>